<template>
	<view class="zai-box">
		<image src="../../static/zaizai-login/login.jpg" mode='aspectFit' class="zai-logo"></image>
		<!-- <view class="zai-title">LOGO区域</view> -->
		<view class="zai-form">
			<input class="zai-input" v-model="form.mobile" placeholder="请输入手机号" />
			<input class="zai-input" v-model="form.username" placeholder="请输入用户名" />
			<input class="zai-input" v-model="form.password" password placeholder="请输入密码" />
			<input class="zai-input" v-model="form.password1" password placeholder="请再输入一次密码" />
			<button class="zai-btn" @click="register">立即注册</button>
			<view class="zai-label" @click="jump">已有账号，点此去登录.</view>
			<!-- <navigator url="/pages/login/index" open-type='navigateBack' hover-class="none" class="zai-label"></navigator> -->
		</view>
		<u-notify ref="uNotify"></u-notify>
	</view>
</template>

<script>
	import {
		ResultEnum
	} from '@/enums/httpEnum.js'
	export default {
		data() {
			return {
				form: {
					identity: 'USER'
				}
			}
		},
		methods: {

			jump() {
				uni.navigateTo({
					url: '/pages/login/index'
				})
			},
			register() {
				// console.log(this.form.mobile.length);
				if (this.form.mobile.length != 11) {
					this.$refs.uNotify.warning('请输入正确的手机号')
				} else if (this.form.password != this.form.password1) {
					this.$refs.uNotify.warning('两次密码不一致')
				} else {
					if(!this.form.username){
						this.form.username = '鸡你太美'
					}
					this.$api({
						url: '/auth/register',
						method: 'post',
						data: this.form
					}).then(res => {
						
						const {
							data
						} = res
						if (data.code == ResultEnum.SUCCESS) {
							this.$refs.uNotify.primary(data.message)
							setTimeout(() => {
								this.jump()
							}, 1000)
						}else{
							this.$refs.uNotify.warning(data.message)
						}

					})
				}
			}
		}
	}
</script>

<style>
	.zai-box {
		padding: 0 100upx;
		position: relative;
	}

	.zai-logo {
		width: 100%;
		width: 100%;
		height: 510upx;
	}

	.zai-title {
		position: absolute;
		top: 0;
		line-height: 360upx;
		font-size: 68upx;
		color: #fff;
		text-align: center;
		width: 100%;
		margin-left: -100upx;
	}

	.zai-form {
		margin-top: 200upx;
	}

	.zai-input {
		background: #e2f5fc;
		margin-top: 30upx;
		border-radius: 100upx;
		padding: 20upx 40upx;
		font-size: 36upx;
	}

	.input-placeholder,
	.zai-input {
		color: #94afce;
	}

	.zai-label {
		padding: 60upx 0;
		text-align: center;
		font-size: 30upx;
		color: #a7b6d0;
	}

	.zai-btn {
		background: #ff65a3;
		color: #fff;
		border: 0;
		border-radius: 100upx;
		font-size: 36upx;
		margin-top: 60upx;
	}

	.zai-btn:after {
		border: 0;
	}

	/*按钮点击效果*/
	.zai-btn.button-hover {
		transform: translate(1upx, 1upx);
	}
</style>
